package testLayer;

import static org.junit.Assert.*;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;

import dbLayer.DBClassRoom;

public class ClassRoomDatabaseTest {
	
	private DBClassRoom dbClassRoom;
	
	@Before
	public void setUp() throws Exception {
		
		this.dbClassRoom = new DBClassRoom();
		this.insert();
		
	}
	
	@After
	public void tearDown() throws Exception {
		
		this.remove();
		this.dbClassRoom = null;
		
	}
	
	public void insert() throws Exception {
		
		this.dbClassRoom.insert("L07b", "blank");
	 	
	}
	
	@Test
	public void  find() throws Exception {
		
		assertTrue(this.dbClassRoom.find("L07b") != null);

	}
	
	@Test
	public void findById() throws Exception {
		
		assertTrue(this.dbClassRoom.findById(this.dbClassRoom.find("L07b").getId()) != null);
		
	}
	
	@Test
	public void getAll() throws Exception {
		
		assertTrue(!this.dbClassRoom.getAll().isEmpty() && 1 <= this.dbClassRoom.getAll().size());

	}
	
	@Test
	public void update() throws Exception {
		
		assertTrue(this.dbClassRoom.update(this.dbClassRoom.find("L07b").getId(),
								  	"L07b", "Common Purpose Lecture Room") > 0);
		
	}
	
	public void remove() throws Exception {
		
		this.dbClassRoom.remove("L07b");
		
	} 

}
